package bTree.LeetCode;

import java.util.Stack;

public class 设计浏览器历史记录 {
    public String[]strings;
    int index=-1;
    int capacity=-1;
    public BrowserHistory(String homepage) {
        strings=new String[101];
        strings[++index]=homepage;
        capacity++;
    }

    public void visit(String url) {
        strings[++index]=url;
        capacity=index;
    }

    public String back(int steps) {
        if(steps>index){
            index=0;
            return strings[0];
        }else {
            index=index-steps;
            return strings[index];
        }
    }

    public String forward(int steps) {
        if(index+steps>capacity){
            index=capacity;
            return strings[capacity];
        }else {
            index=index+steps;
            return strings[index];
        }
    }
}